package com.youfang.sixthmedia.message;

import org.json.JSONObject;

import ch.boye.httpclientandroidlib.Header;

import com.gzit.utils.StringUtils;
import com.youfang.sixthmedia.common.YoufangContext;
import com.youfang.sixthmedia.message.model.User;
import com.youfang.sixthmedia.net.HttpRemoter;
import com.youfang.sixthmedia.net.Response;

public class LoginResponse extends Response {

	private User user = new User();

	@Override
	protected void decodeBody(JSONObject bodyJSON) throws Exception {

		JSONObject data = bodyJSON.getJSONObject("data");
		user.email = getString(data, "email");
		user.introduce = getString(data, "introduce");
		user.ispublic = getInt(data, "ispublic");
		user.logourl = getString(data, "logourl");
		user.userid = getInt(data, "userid");
		user.username = getString(data, "username");
		user.nickname = getString(data, "nickname");
		user.mobile = getString(data, "mobile");
		user.phone = getString(data, "phone");
		user.logourl = getString(data, "logourl");
		user.unreadmsgcnt = getInt(data, "unreadmsgcnt");

	}

	protected void processHeader(Header... header) {
		// for (Header h : header) {
		// if ("Set-Cookie".equalsIgnoreCase(h.getName())) {
		// String content = h.getValue();
		// if (!StringUtils.isBlank(content)) {
		// String[] arr = content.split(";");
		// if (arr.length > 0) {
		// String cookiee = arr[0];
		// String[] mycookie = cookiee.split("=");
		// HttpRemoter.mycookie = mycookie[1];
		// YoufangContext.saveCookie(HttpRemoter.mycookie);
		//
		// }
		//
		// }
		//
		// return;
		// }
		//
		// }

	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
